package com.yy.controller;

import com.yy.common.Resault;
import com.yy.domain.Bicycle;
import com.yy.dto.BicycleDTO;
import com.yy.service.BicycleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("bicycle")
public class BicycleController {
    @Autowired
    private BicycleService bicycleService;

    /**
     * 接口说明：会员在使用单车时需要分页展示出所有未被使用的单车
     * 请求方式：GET
     * 请求url：/bicycle-service/bicycle/getBicycle
     * 请求参数说明：
     * 分页参数
     */
    @GetMapping("/getBicycle")
    public Resault<List<Bicycle>> getBicycle(BicycleDTO bicycleDTO){
        Resault<List<Bicycle>> bicycleList=this.bicycleService.queryAllBicycle(bicycleDTO);
        return bicycleList;
    }


    /**
     * 根据Id查询单车信息
     */
    @GetMapping("/getBicycleById")
    public Bicycle getBicycleById(@RequestParam("bicycleId") Integer bicycleId){
        return this.bicycleService.getBicycleById(bicycleId);
    }

    /**
     * 修改单车信息
     */
    @PostMapping("/updateBicycle")
    public Resault updateBicycle(@RequestBody Bicycle bicycle){
        int row=this.bicycleService.updateBicycle(bicycle);
        return new Resault(200,"修改成功");
    }




}
